using System.ComponentModel.DataAnnotations;
using System.ComponentModel.DataAnnotations.Schema;
using System.Data.Entity.ModelConfiguration;
using SalesPages.DomainModel;

namespace SalesPages.EntityFrameworkRepository.Mapping
{
    public class E1ContentVariableMap : EntityTypeConfiguration<E1ContentVariable>
    {
        public E1ContentVariableMap()
        {
            // Primary Key
            this.HasKey(t => new { t.Variable_id, t.SiteVersion });

            // Properties
            this.Property(t => t.Variable_id)
                .HasDatabaseGeneratedOption(DatabaseGeneratedOption.None);

            this.Property(t => t.SiteVersion)
                .IsRequired()
                .HasMaxLength(50);

            this.Property(t => t.KeyName)
                .IsRequired()
                .HasMaxLength(100);

            this.Property(t => t.DefaultValue)
                .IsRequired()
                .HasMaxLength(500);

            this.Property(t => t.Descr)
                .IsRequired()
                .HasMaxLength(100);

            // Table & Column Mappings
            this.ToTable("E1ContentVariable");
            this.Property(t => t.Variable_id).HasColumnName("Variable_id");
            this.Property(t => t.SiteVersion).HasColumnName("SiteVersion");
            this.Property(t => t.KeyName).HasColumnName("KeyName");
            this.Property(t => t.DefaultValue).HasColumnName("DefaultValue");
            this.Property(t => t.Descr).HasColumnName("Descr");
            this.Property(t => t.InsertDate).HasColumnName("InsertDate");
            this.Property(t => t.UpdateDate).HasColumnName("UpdateDate");
        }
    }
}
